package course.p6_queue;

import org.junit.Assert;
import org.junit.Test;

import java.util.ArrayDeque;
import java.util.Optional;
import java.util.Queue;
import java.util.Random;

public class QueueTest {

    private final Queue<Integer> rightQueue = new ArrayDeque<>();


    @Test
    public void queueTest(){
        LinkQueue queue = new LinkQueue(100);
        for (int i=0;i<1000;i++){
            boolean active = new Random().nextBoolean();
            if(active){
                rightQueue.offer(i);
                queue.offer(i);
            }else {
                Assert.assertEquals(rightQueue.isEmpty(),queue.isEmpty());
                if(!rightQueue.isEmpty()){
                    Assert.assertEquals(Optional.ofNullable(rightQueue.poll()),Optional.of(queue.poll()));
                }
            }
        }
    }


}
